package com.rd.student.ruanjian.class4.baiyunyao.DAY0728;

import java.util.Random;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
    public class dianmingqi {
        public static void main(String[]args){
            String[]list={"李春泉","杜航","周子贺","高艺铭","张瑞","王星凯","柏云耀"};
            Random random = new Random();
            int name = random.nextInt(list.length);
            for (int i = 0; i<= list.length;i++){
                if (name==i){
                    System.out.println("被点名的同学是："+(name+1)+"号"+list[name]+"同学");
                }
            }

        }
    }
    class dianmingqi2{
        public static void main(String[] args) throws IOException {

            RandomRollCall4();

        }
        private static void RandomRollCall4() throws IOException {

            ArrayList<String> list = new ArrayList<>();

            BufferedReader br = new BufferedReader(new FileReader("src\\MyUrl\\information.txt"));
            String line;
            while (true){

                if ((line= br.readLine())!=null){
                    list.add(line.split("-")[0]);
                }else if (list.size()==0){

                    Object refresh = new Object();
                    refresh.getClass();
                }else {
                    break;
                }
            }
            br.close();
            Random r =new Random();
            int i = r.nextInt(list.size());
            System.out.println(list.remove(i));

        }


        private static void RandomRollCall3() throws IOException {

            BufferedReader br = new BufferedReader(new FileReader("src\\MyUrl\\count.txt"));
            String line;
            line= br.readLine();
            br.close();

            FileWriter fw = new FileWriter("src\\MyUrl\\count.txt");
            fw.write(Integer.parseInt(line)+1+"");
            fw.close();

            if ((Integer.parseInt(line)+1)%3==0){
                System.out.println("李春泉");
                return;
            }
            RandomRollCall1();
        }

        private static void RandomRollCall1() {
        }
    }


